import '@nomicfoundation/hardhat-ethers'
import 'hardhat-deploy'
import { task } from 'hardhat/config'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import { MyToken } from '../typechain-types'

export const checkNFT = task('check-nft').setAction(async (taskArgs, hre: HardhatRuntimeEnvironment) => {
  const { firstAccount } = await hre.getNamedAccounts()
  const nft = await hre.ethers.getContract<MyToken>('MyToken', firstAccount)
  const totalSupply = await nft.totalSupply()

  console.log('checking status of MyToken')

  for (let tokenId = 0; tokenId < totalSupply; tokenId++) {
    const owner = await nft.ownerOf(tokenId)
    console.log(`Token ID: ${tokenId}, Owner: ${owner}`)
  }
})
